<template>
	<view class="p_content">
		<view
			class="item_content"
			v-for="(item, index) in viewList"
			:key="index"
			@click="itemClick(index)">
			<image :src="item.img | mmvImageUrl" mode="scaleToFill" v-if="false"></image>
			<text>{{ item.value }}</text>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				querychoice: {},
				activitiEnable: {},
				viewList: [],
			};
		},
		onLoad() {
			this.querychoice = this.$store.state.params.getCarCommon;
			this.activitiEnable = this.$store.state.params.activitiEnable;

			if (
				!uni.$u.test.isEmpty(this.querychoice) &&
				!uni.$u.test.isEmpty(this.querychoice.leaseType)
			) {
				this.viewList = this.querychoice.leaseType;

				console.log('=======viewlist====', this.viewList);
			}
		},
		methods: {
			itemClick(index) {
				if (uni.$u.test.isEmpty(this.activitiEnable)) {
					return;
				}

				let code = this.viewList[index].code;

				getApp().globalData.addOrderIntentData = this.viewList[index];
				if (code >= 1 && code <= 8) {
					if (1 == this.activitiEnable.longRentOrderApprove) {
						//长租有工作流
						uni.navigateTo({
							url: `/pagesB/addorder/addorder-workflow?code=${code}`,
						});
					} else {
						//长租无工作流
						uni.navigateTo({
							url: `/pagesB/addorder/addorder?code=${code}`,
						});
					}
				}

				// //1经租  2以租代购  3展示车  4试驾车  5融租  6直购 7挂靠 8直营
				// if (1 == code || 3 == code || 4 == code) {
				// 	if (1 == this.activitiEnable.longRentOrderApprove) {
				// 		//长租有工作流
				// 		uni.navigateTo({
				// 			url: '/pagesB/addorder/addorder-workflow',
				// 		});
				// 	} else {
				// 		//长租无工作流
				// 		uni.navigateTo({
				// 			url: '/pagesB/addorder/addorder',
				// 		});
				// 	}
				// } else if (2 == code) {
				// 	if (1 == this.activitiEnable.rentSaleOrderApprove) {
				// 		//租售有工作流
				// 		uni.navigateTo({
				// 			url: '/pagesB/addorder/addorder-workflow',
				// 		});
				// 	} else {
				// 		//租售无工作流
				// 		uni.navigateTo({
				// 			url: '/pagesB/addorder/addorder',
				// 		});
				// 	}
				// } else if (5 == code) {
				// 	if (1 == this.activitiEnable.meltsRentOrderApprove) {
				// 		uni.navigateTo({
				// 			url: '/pagesB/addorder/addorder-workflow',
				// 		});
				// 	} else {
				// 		uni.navigateTo({
				// 			url: '/pagesB/addorder/addorder',
				// 		});
				// 	}
				// } else if (6 == code) {
				// 	if (1 == this.activitiEnable.purchaseOrderApprove) {
				// 		uni.navigateTo({
				// 			url: '/pagesB/addorder/addorder-workflow',
				// 		});
				// 	} else {
				// 		uni.navigateTo({
				// 			url: '/pagesB/addorder/addorder',
				// 		});
				// 	}
				// } else if (7 == code) {
				// 	if (1 == this.activitiEnable.purchaseOrderApprove) {
				// 		uni.navigateTo({
				// 			url: '/pagesB/addorder/addorder-workflow',
				// 		});
				// 	} else {
				// 		uni.navigateTo({
				// 			url: '/pagesB/addorder/addorder',
				// 		});
				// 	}
				// } else if (8 == code) {
				// 	if (1 == this.activitiEnable.purchaseOrderApprove) {
				// 		uni.navigateTo({
				// 			url: '/pagesB/addorder/addorder-workflow',
				// 		});
				// 	} else {
				// 		uni.navigateTo({
				// 			url: '/pagesB/addorder/addorder',
				// 		});
				// 	}
				// }
			},
		},
	};
</script>

<style lang="scss" scoped>
	.p_content {
		display: flex;
		flex-direction: column;
	}

	.item_content {
		border-radius: 16rpx;
		background-color: #fff;
		margin: 20rpx 20rpx 0;
		height: 160rpx;
		display: flex;
		align-items: center;
		padding-left: 50rpx;

		image {
			width: 83rpx;
			height: 83rpx;
		}

		text {
			margin-left: 36rpx;
			font-size: 36rpx;
			color: black;
		}
	}
</style>
